﻿$(document).ready(function() {

    $.fn.preload = function() {
        this.each(function() {
            $('<img/>')[0] = new Image();
            $('<img/>')[0].src = this;
        });

    }


    $('img.corporate_logo, img.supporting_logo, img.roll_over_button').each(function() {
        var t = $(this);
        var newSource = t.attr('src'); // initial src
        $([newSource, newSource.replace("_bw", "_over")]).preload(); //preload images on page load

        t.hover(function() {
            $(this).attr('src', newSource.replace("_bw", "_over")); //last part is for extension
            //$(this).attr('class', "supporting_logo_over"); //last part is for extension
        }, function() {
            $(this).attr('src', newSource); //removing '-over' from the name
            //$(this).attr('class', "supporting_logo"); //removing '-over' from the name
        });
    });


});